package com.example.makerspace.controller;


import com.example.makerspace.dto.ContactInfoDTO;
import com.example.makerspace.dto.PageRequest;
import com.example.makerspace.dto.PageResult;
import com.example.makerspace.dto.Result;
import com.example.makerspace.service.CoalitionService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Controller
@ResponseBody
@RequestMapping("/api/coalition")
public class CoalitionController {

    @Resource
    private CoalitionService coalitionService;
    @PostMapping("/addContact")
    public Result addContact(@RequestBody ContactInfoDTO contactInfoDTO, HttpServletRequest request){
        return  coalitionService.addContactInfo(contactInfoDTO, request);
    }
    @PostMapping("/contactDetail")
    public Result contactDetail(@RequestBody ContactInfoDTO contactInfoDTO, HttpServletRequest request){
        return  coalitionService.contactDetail(contactInfoDTO, request);
    }

    @PostMapping("/demandList")
    public PageResult demandList(@RequestBody PageRequest pageRequest){
        return coalitionService.demandList(pageRequest);
    }

    @PostMapping("/technicList")
    public PageResult technicList(@RequestBody PageRequest pageRequest){
        return coalitionService.technicList(pageRequest);
    }

    @PostMapping("/companyList")
    public PageResult companyList(@RequestBody PageRequest pageRequest){
        return coalitionService.companyList(pageRequest);
    }

    @PostMapping("/categoryList")
    public Result categoryList(@RequestBody Map<String, String> params){
        return coalitionService.categoryList(params);
    }
}
